package com.theyeasy.dvmini.controller;

import com.google.common.base.Strings;
import com.theyeasy.dvmini.config.PCLoginConfig;
import com.theyeasy.dvmini.dataobject.vo.Vo_msg;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/home")
public class LoginController extends BaseController {

    @RequestMapping("/login")
    public ModelAndView login(){
        ModelAndView mv = new ModelAndView("/pc/login");
        return mv;
    }
    
    @RequestMapping("/loginIn")
    public @ResponseBody
    Vo_msg agentlogon(String account, String pwd) {
        if (Strings.isNullOrEmpty(account))
            return new Vo_msg(-1, "登录失败，账号不能为空");
        if (Strings.isNullOrEmpty(pwd))
            return new Vo_msg(-1, "登录失败，密码不能为空");
        // 获取配置的用户名和密码
        PCLoginConfig login = new PCLoginConfig();
        System.out.println("account:" + login.getAccount() + ",pwd:" + login.getPwd());
        if (account.equals(login.getAccount()) && pwd.equals(login.getPwd())) {

            return new Vo_msg(0, "ok");
        } else {
            return new Vo_msg(-1, "登录失败，用户名或密码错误");
        }
    }

}
